<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm');?>

<div class="row">
	<div class="col-lg-12">
		<div class="btn-group mb-3" role="group">
			<?php echo admin_tab_active($menu['forum']['tab'], 'info');?>
		</div>
		<div class="card">
			<div class="card-body">
				<form action="<?php echo url('forum-info');?>" method="post" id="form">
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">选择要修改的用户组：</label>
						<div class="col-sm-10">
							<select class="custom-select" name="fid">
								<?php foreach ($forumlist as $fid => $_forump) { ?>
									<option value="<?php echo $_forump['fid'] ?>"><?php echo $_forump['name'] ?></option>
								<?php } ?>
							</select>
						</div>
                    </div>
                    
                    <div class="form-group row">
                        <label class="col-sm-2 form-control-label">选择要修改的信息列：</label>
                        <div class="col-sm-10">
                            <select class="custom-select" name="iid">
                            </select>
                        </div>
                    </div>

					<div class="form-group row">
						<label class="col-sm-2 form-control-label">信息列名称：</label>
						<div class="col-sm-10">
							<input type="text" name="info_name" class="form-control" />
						</div>
					</div>

					<div class="form-group row">
						<label class="col-sm-2 form-control-label">信息列显示名称：</label>
						<div class="col-sm-10">
							<input type="text" name="info_show_name" class="form-control" />
						</div>
					</div>

					<div class="form-group row">
						<label for="inputPassword3" class="col-sm-2 form-control-label"></label>
						<div class="col-sm-10">
							<button type="submit" class="btn btn-primary btn-block" id="submit" data-loading-text="<?php echo lang('submiting');?>..."><?php echo lang('confirm');?></button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>

<script type="text/javascript">
	var forumlist = <?php echo json_encode($forumlist); ?>;
    var fidselect = $('select[name="fid"]');
    var iidselect = $('select[name="iid"]');
	var info_name = $('input[name="info_name"]');
	var info_show_name = $('input[name="info_show_name"]');

	var fid = fidselect.val();

	fidselect.on('change',function(){
        var fid = fidselect.val();
        console.log(fid);
        iidselect.empty();

        iidselect.append("<option value='new'>"+ "新建信息列" +"</option>")

        if(forumlist[fid]['info'] != null){
            infolist = forumlist[fid]['info'];
        }

    })
    iidselect.on('change',function(){
        var fid = fidselect.val();
        var iid = iidselect.val();
    })


</script>

<script>
var jform = $('#form');
var jsubmit = $('#submit');

jform.on('submit', function() {
	jform.reset();
	jsubmit.button('loading');
	
	var postdata = jform.serializeObject();

	$.xpost(jform.attr('action'), postdata, function(code, message) {
		if(code == 0) {
			$.alert(message);
			jsubmit.button(message).delay(3000).button('reset');
		} else if(xn.is_number(code)) {
			alert(message);
			jsubmit.button('reset');
		} else {
			jform.find('[name="'+code+'"]').alert(message).focus();
			jsubmit.button('reset');
		}
	});
	return false;
});
</script>